<style lang="scss">
    @import './login.scss';
</style>

<template>
    <div class="login">
        <div class="login-con">
            <Card icon="log-in" title="欢迎登录" :bordered="false">
                <div class="form-con">
                    <login-form @on-success-valid="handleSubmit"></login-form>
                </div>
            </Card>
        </div>
    </div>
</template>

<script>
    import LoginForm from '../../components/login-form'
    import {mapActions} from 'vuex'

    export default {
        components: {
            LoginForm
        },
        methods: {
            ...mapActions('user',['Login','getUserInfo']),
            handleSubmit({userName, password,remember}) {
                this.Login({ userName, password,remember }).then(access_token => {
                  this.getUserInfo(access_token).then(res => {
                    this.$router.replace({
                      name: 'dashboard'
                    })
                  }).catch((error)=>{

                  })
                }).catch((error)=>{

                });
            },
        }
    }
</script>

<style>

</style>
